Accessing the objects that the SDK provides is typically started by creating an "instance" of the TurboCAD Application object. Each client application program gets its own copy of the TurboCAD Application object, which represents an editing or viewing session. These sessions are independent of each other.
Creating or Connecting to the Application Object
You can create Automation client applications using Microsoft Visual Basic, Microsoft Visual C++, Enable Basic, or any other application or programming language that supports ActiveX technologies. Your client needs to perform the following steps to access TurboCAD's exposed objects:
- Initialize and create the object
- Initialize OLE
- Create an instance of the exposed object
- Manipulate the object
- Get information about the object's methods an properties
- Invoke methods and properties
- Release OLE when your application or tool exits
- Release the active object
- Un-initialize OLE
Choosing In Process or Local Server
The TurboCAD v4 OLE Automation server can be loaded as an in process (DLL) server, in a custom client application's process with a user interface provided by the client application that you provide. In this way you can read files, create drawings, add, modify and delete graphics, and display drawings on your application's user-defined viewports.
The TurboCAD v4 OLE Automation server can also be run as a local (EXE) server. In this scenario the objects are provided by the TurboCAD v4 application (TCW40.exe), and your client can control and customize the operation of TurboCAD, adding user interface elements, receiving events fired by TurboCAD, and extending the operation of TurboCAD. If TurboCAD has been launched by a user, your client application can also connect to the active running instance of TurboCAD.
In general, in-process servers run faster than local servers. The in-process server is contained in IMSIGX40.DLL, together with support from DBAPI40.DLL, TCAPI40.DLL, and a variety of graphic regeneration method and drawing file format filter DLLs. Use the local server option when you require TurboCAD's user interface (menus, toolbars and windows).
Creating a New Application Object Instance
Each language has a function that is used to create objects in the OLE Automation system. In Visual Basic, the
CreateObject
function starts up a connection to the server. The CreateObject function takes one argument, a string called the ProgID, with which the OLE Automation system gets information from the Windows registry to locate the TurboCAD server. The in process and local servers have distinct ProgIDs, so make sure you use the correct string. After locating the server the system starts up the server and requests an object.From Visual Basic:
Set App = CreateObject("IMSIGX.Application.4")
will start up the in-process (DLL) server, andSet App = CreateObject("TurboCAD.Application.4")
will start up the local (EXE) server.In Delphi, the same result is accomplished by using the
CreateOleObject
function in theOleAuto
unit.:
App := CreateOleObject('IMSIGX.Application.4');
will start up the in-process (DLL) server, andApp := CreateOleObject('TurboCAD.Application.4');
will start up the local (EXE) server.In Visual J++, the same result is accomplished by instantiating a new
imsigx40.XApplication
orimsigx40.Application
object and assigning the result to a reference of theimsigx40.IApplication
interface.
imsigx40.IApplication iApp = (imsigx40.IApplication) new imsigx40.XApplication();
will start up the in-process (DLL) server, andimsigx40.IApplication iApp = (imsigx40.IApplication) new imsigx40.Application();
will start up the local (EXE) server.Finally in C++, or other languages that allow direct calls to the Win32 API, the choice between in process and local servers is also determined by the
dwClsContext
argument to theCoCreateInstance
function:
CoCreateInstance(CLSID_XApplication, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, &pIApp)
will start up the in-process (DLL) server, andCoCreateInstance(CLSID_Application, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, &pIApp)
will start up the local (EXE) server.Connecting to a Running Application Object
Each language also has the ability to connect to an already running copy of TurboCAD.
SDK Top API Reference TurboCAD Home Page TurboCAD Programming Forums